using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

namespace shfa.snomtastic.data
{
    public partial class SqlDataProvider
    {

        public Guid InsertCategory(string name)
		{
            return new Guid(Convert.ToString(SqlHelper.ExecuteScalar(ConnectionString, "sp_CategoryInsert", name)));
		}

        public int UpdateCategory(Guid categoryId, string name)
		{
            return Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, "sp_CategoryUpdate", GetNull(categoryId), name));
		}

        public int DeleteCategory(Guid categoryId) 
		{
            return Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, "sp_CategoryDelete", categoryId));
		}

        public DataRow SelectCategory(Guid categoryId) 
        {    
			DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, "sp_CategorySelect", categoryId);
            if (ds.Tables.Count > 0)
                if (ds.Tables[0].Rows.Count > 0)
                    return ds.Tables[0].Rows[0];

            return null;
		}

		public DataTable SelectCategories() 
		{
            return SqlHelper.ExecuteDataset(ConnectionString, "sp_CategorySelectAll").Tables[0];
        }

    }

}
